class ReportsController < ApplicationController
  def index
    @search = session[:search] || Search.new
    @impt_search = Search.find_or_create_by_query("pertinent:yes")
    begin
      @reports = Report.all_by_page(params[:page], @search.conditions)
      render(:partial => "table_only", :locals => {:reports => @reports}) if ajax_request?
    rescue
      @search = Search.new
      @reports = Report.all_by_page(params[:page])
      flash[:error] = $!.to_s
    end
  end

  def change_importance
    r = Report.find(params[:id])
    r.important = params[:updated] == "?" ? nil : params[:updated]
    r.mark_reason = "Manual"
    r.save
    render(:nothing => true)
  end
end